package com.sgcc.sx.pmos.e_sx_home.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.sx.pmos.e_sx_home.bean.DynamicBean;
import com.sgcc.sx.pmos.e_sx_home.bean.UserTypeHistoryBean;

public class UserTypeHisAdapter extends BaseQuickAdapter<UserTypeHistoryBean.DataDTO.ListDTO, BaseViewHolder> {

    private Context mContext;

    public UserTypeHisAdapter(Context context) {
        super(R.layout.item_userhis);
        mContext = context;
    }

    public interface OnItemClickListener {
        //条目点击
        void itemClickListener(int position, DynamicBean bean);
    }

    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, UserTypeHistoryBean.DataDTO.ListDTO bean) {
        baseViewHolder.setText(R.id.tv_time_top, bean.getChangeDate());
        baseViewHolder.setText(R.id.tv_usertypehis, getUserType(bean.getHisType()));
        baseViewHolder.setText(R.id.tv_usertype, getUserType(bean.getUserType()));
        baseViewHolder.setText(R.id.tv_time,bean.getStartDate()+"至"+bean.getEndDate());
        baseViewHolder.setText(R.id.tv_user, bean.getUpdatepersonName());
    }


    public static String getUserType(String typeNum) {
        String userType = "";
        if(TextUtils.isEmpty(typeNum)){
            userType="目标月暂无身份信息";
        }else{
            switch (typeNum) {
                case "1":
                    userType = "直接交易用户";
                    break;
                case "2":
                    userType = "零售用户";
                    break;
                case "3":
                    userType = "电网公司代理用户（1.0 倍）";
                    break;
                case "4":
                    userType = "电网公司代理用户（1.5 倍)";
                    break;
            }
        }

        return userType;
    }
}
